<?php
/**
 * Desc:
 * Auth: Shaoming Lu
 * Date: 2018/4/9
 * Time: 18:10
 */
namespace echophp\core;

class Request
{
    private $request;
    private $get;
    private $post;

    public function __construct()
    {
        $this->request = $_REQUEST;
        $this->get = $_GET;
        $this->post = $_POST;
    }

    /**
     * 获取请求参数，get post参数都可以获取
     * @access  public
     * @author  Lu Shaoming<lushao1012@163.com>
     * @param $name
     * @return null
     */
    public function input($name)
    {
        if (isset($this->request[$name])) {
            return $this->request[$name];
        } else {
            return null;
        }
    }

    /**
     * 获取get请求参数
     * @access  public
     * @author  Lu Shaoming<lushao1012@163.com>
     * @param $name
     * @return null
     */
    public function get($name)
    {
        if (isset($this->get[$name])) {
            return $this->get[$name];
        } else {
            return null;
        }
    }

    /**
     * 获取post请求参数
     * @access  public
     * @author  Lu Shaoming<lushao1012@163.com>
     * @param $name
     * @return null
     */
    public function post($name)
    {
        if (isset($this->post[$name])) {
            return $this->post[$name];
        } else {
            return null;
        }
    }

    /**
     * 获取请求方式
     * @access  public
     * @author  Lu Shaoming<lushao1012@163.com>
     * @return mixed
     */
    public function method()
    {
        return $_SERVER['REQUEST_METHOD'];
    }
}